import {GET_IMAGE_LIST,GET_CATEGORY,CHANGE_DIALOG,INIT_CATEGORY,CHANGE_INDEX} from '../actionTypes';
export default (state={
    imageList:[],
    categoryList:[],
    Count:0,
    swiperoOpen:false,
    activeIndex:-1
},action) => {
    switch (action.type) {
        case GET_IMAGE_LIST:{
            let {list} = action;
            return {
                ...state,
                imageList:[...list]
            }
        }
        //获取对应分类的图片列表
        case GET_CATEGORY:{
            let {data} = action;
            return {
                ...state,
                categoryList:[...state.categoryList,...data.List],  //对应分类的图片列表
                Count:data.Count              //总条数
            }
        }
        //初始化数据
        case INIT_CATEGORY:{
            return {
                ...state,
                categoryList:[],
                Count:0
            }
        }
        //修改弹窗是否打开
        case CHANGE_DIALOG:{
            let {isOpen} = action;
            return {
                ...state,
                swiperoOpen:isOpen
            }
        }
        //修改activeIndex
        case CHANGE_INDEX:{
            let {index} = action;
            return {
                ...state,
                activeIndex:index
            }
        }
        default:{
            return state
        }
    }
}